<template>
	<view class="dzList">
		<view class="item" v-if="isShow(item)" v-for="(item, i) in list" :key="i"  @click="toNav(`address/editAddress?id=${item.id}`)">
			<view class="lbox">
				<image v-if="item.if_default" class="icon" src="@/static/images/mrdz.png" mode="aspectFit"></image>
				<u-avatar v-else :text="item.name.slice(0, 1)" size="56rpx" fontSize="12" randomBgColor></u-avatar>
			</view>
			<view class="infobox">
				<view class="row">
					<text>{{ item.name }}</text>
					<text>{{ item.phone }}</text>
					<text v-if="item.if_default">[默认地址]</text>
				</view>
				<view class="row2">
					<text>{{ item.areaName }}</text>
					<text class="line-1">{{ item.address }}</text>
				</view>
			</view>
			<image class="edit" src="@/static/images/edit.png" mode="aspectFit"></image>
		</view>
	</view>
</template>

<script>
export default {
	name: 'dzList',
	computed: {
		isShow() {
			return (data) => {
				if (this.mr) {
					return data.if_default === 1;
				} else {
					return !data.if_default;
				}
			};
		}
	},
	props: {
		mr: {
			type: Boolean,
			default: false
		},
		list: {
			type: Array | Number,
			default: () => {
				return [];
			}
		}
	},
	data() {
		return {};
	}
};
</script>

<style lang="less" scoped>
.dzList {
	display: flex;
	flex-direction: column;
	.item + .item {
		border-top: 1rpx solid #f3f4f8;
	}
	.item {
		display: flex;
		align-items: center;
		height: 196rpx;
		padding: 34rpx 24rpx;
		background: #ffffff;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		.j-active2();
		.lbox {
		}
		.icon {
			width: 56rpx;
			height: 56rpx;
			background: #f5f5f5;
			border-radius: 50%;
		}
		.infobox {
			flex: 1;
			margin-left: 24rpx;
			height: 100%;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			.row {
				display: flex;
				align-items: center;
				text:nth-of-type(1) {
					margin-right: 24rpx;
					font-size: 28rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					color: #000000;
				}
				text:nth-of-type(2) {
					margin-right: 32rpx;
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #333333;
				}
				text:nth-of-type(3) {
					font-size: 24rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #ff0000;
				}
			}

			.row2 {
				display: flex;
				flex-direction: column;
				text + text {
					margin-top: 6rpx;
				}
				text {
					font-size: 24rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #000000;
				}
			}
		}
		.edit {
			width: 40rpx;
			height: 40rpx;
			.j-active();
		}
	}
}
</style>
